// #include"./tinyxml2-master/tinyxml2.h"
// #include"./tinyxml2-master/tinyxml2.cpp"
#include"txBodyReader.cpp"
#include"spPrReader.cpp"
#include<iostream>
#include<vector>

using namespace std;
using namespace tinyxml2;
TextFrame *txBodyReader(tinyxml2::XMLElement *node);
ShapePro *spPrReader(tinyxml2::XMLElement *node);

int main(){
    vector<TextFrame*> vec_txBody;
    vector<ShapePro*> vec_spPr;
    tinyxml2::XMLDocument doc;
    doc.LoadFile( "./ppt/455/ppt/slides/slide1.xml");

    tinyxml2::XMLElement *rootElement = doc.RootElement();
    tinyxml2::XMLElement *cSld = rootElement->FirstChildElement();
    tinyxml2::XMLElement *spTree = cSld->FirstChildElement();
    tinyxml2::XMLElement *sp = spTree->FirstChildElement("p:sp");
    while(sp){
        ShapePro* ShapePro2 = spPrReader(sp);
        vec_spPr.push_back(ShapePro2);
        sp = sp->NextSiblingElement("p:sp");
        
        TextFrame* m_text_frame1 = txBodyReader(sp);
        vec_txBody.push_back(m_text_frame1);
        sp = sp->NextSiblingElement("p:sp");  
    }

    tinyxml2::XMLElement *cxnSp = spTree->FirstChildElement("p:cxnSp");
    while(cxnSp){
        ShapePro* ShapePro3 = spPrReader(cxnSp);
        vec_spPr.push_back(ShapePro3);
        cxnSp = cxnSp->NextSiblingElement("p:cxnSp");
    }

    cout << "#####################SpPr Reading#####################" << endl;
    int size0 = vec_spPr.size();
    for (int i = 0; i < size0; i++){
        cout << "x: " << vec_spPr[i]->GetTrans2d().GetX() << endl;
        cout << "y: " << vec_spPr[i]->GetTrans2d().GetY() << endl;
        cout << "cx: " << vec_spPr[i]->GetTrans2d().GetCX() << endl;
        cout << "cy: " << vec_spPr[i]->GetTrans2d().GetCY() << endl;
        cout << "prst: " << vec_spPr[i]->GetPrst2d().GetPrstGeometry2D() << endl;
        cout << "val: " << vec_spPr[i]->GetFill().GetFill() << endl;
        cout << "gd_name: " << vec_spPr[i]->GetPrst2d().GetPrstGeometry2D_name() << endl;
        cout << "gd_fmla: " << vec_spPr[i]->GetPrst2d().GetPrstGeometry2D_fmla() << endl;
        cout << "type: " << vec_spPr[i]->GetLine().GetLineType() << endl;
    }

    cout << "#####################txBody Reading#####################" << endl;
    int size = vec_txBody.size();
    for (int i = 0; i < size; i++){
        cout << "rtlCol: " << vec_txBody[i]->GetProp().GetColrtl() << endl;
        cout << "anchor: " << vec_txBody[i]->GetProp().GetAnchor() << endl;
        cout << "wrap: " << vec_txBody[i]->GetProp().GetTextWrap() << endl;
        cout << "algn: " << vec_txBody[i]->GetTextStream().GetPapTbl().p_data_.GetPabsObject().GetPapProp().GetAlignMode() << endl;
        cout << "rPr_lang: " << vec_txBody[i]->GetTextStream().GetChpTbl().c_data_.GetCabsObject().GetChpProp().GetLang() << endl;
        cout << "rPr_altLang: " << vec_txBody[i]->GetTextStream().GetChpTbl().c_data_.GetCabsObject().GetChpProp().GetAltLang() << endl;
        cout << "t: " << vec_txBody[i]->GetTextStream().GetText() << endl;
        // cout << "endParaRPr_lang: " << vec_txBody[i]->GetTextStream().GetChpTbl().c_data_.GetCabsObject().GetChpProp().m_language_0 << endl;
        // cout << "endParaRPr_altLang: " << vec_txBody[i]->GetTextStream().GetChpTbl().c_data_.GetCabsObject().GetChpProp().m_alt_language_0 << endl;
    }

    return 0;
}